BDMS-470: Migrate Stratigraphy#393
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
This PR adds support for ingesting legacy stratigraphy data from Stratigraphy.csv into a dedicated NMA_Stratigraphy table. Previously, stratigraphy rows weren't preserved as first-class records outside of association transfers.
Changes:
- Added NMA_Stratigraphy table model with relationship to Thing
- Implemented batch upsert transfer pipeline for Stratigraphy.csv with environment flag control
- Added tests covering model relationships and end-to-end CSV ingestion
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| alembic/versions/1d2c3b4a5e67_create_nma_stratigraphy_table.py | Creates NMA_Stratigraphy table schema with indexes and foreign key to Thing |
| db/nma_legacy.py | Defines Stratigraphy model with columns for lithology log data |
| db/thing.py | Adds stratigraphy_logs relationship to Thing model |
| transfers/stratigraphy_legacy.py | Implements StratigraphyLegacyTransferer with CSV parsing and batch upsert logic |
| transfers/transfer.py | Integrates stratigraphy legacy transfer into parallel and sequential execution paths |
| transfers/metrics.py | Adds nma_stratigraphy_metrics method for tracking transfer results |
| tests/test_stratigraphy_legacy.py | Tests model relationships and transfer functionality |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| if isinstance(value, str): | ||
| trimmed = value.strip() | ||
| return trimmed or None | ||
| return str(value) |
There was a problem hiding this comment.
The _string_value method converts non-string, non-None values to strings, which may silently coerce unexpected types. Consider adding validation or logging when converting non-string values to help catch data quality issues in the CSV.
| return str(value) | |
| # Log when coercing non-string values to string to help catch data-quality issues. | |
| logger.warning( | |
| "Coercing non-string value to string in StratigraphyLegacyTransferer._string_value: " | |
| "value=%r (type=%s)", | |
| value, | |
| type(value).__name__, | |
| ) | |
| try: | |
| coerced = str(value) | |
| except Exception: | |
| logger.exception( | |
| "Failed to coerce value to string in StratigraphyLegacyTransferer._string_value: " | |
| "value=%r (type=%s)", | |
| value, | |
| type(value).__name__, | |
| ) | |
| return None | |
| trimmed = coerced.strip() | |
| return trimmed or None |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nto BDMS-470-Migrate-Stratigraphy
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nto BDMS-470-Migrate-Stratigraphy
Why
This PR addresses the following problem / context:
How
Implementation summary - the following was changed / added / removed:
Notes
Any special considerations, workarounds, or follow-up work to note?